package com.janwen.spring.trx.declarative;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("trxNestedService")
public class TrxNestedService extends TrxBaseService {

	@Autowired
	private TrxAddService addService;
	public void deleteStuff(String name, int age) {
		String sql = "DELETE sf FROM stuff sf WHERE sf.name=? AND sf.age=?";
		getJdbcTemplate().update(sql, name, age);
	}

	public void nestedTrx(String name,int age){
		addService.nestedAddTrx(name, age);
		deleteStuff(name, age);
	}
	public int queryAge(String name) {
		String sql = "SELECT sf.age FROM stuff sf WHERE sf.name=?";
		return getJdbcTemplate().queryForInt(sql, name);
	}
}
